import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../common/components/layout/Layout'
// import Test from '../common/components/layout/Test'
Vue.use(Router)

export const constantRouterMap = [
  { path: '/login', component: _import('login/view/login') },

  {
    path: '/',
    // component: Test
    component: Layout,
    redirect: '/home',
    name: 'Home',
    children: [{ path: 'home', component: _import('home/view/home') }]
  },
  {
    path: '/user',
    component: Layout,
    name: 'user',
    children: [{ path: 'list', component: _import('user/view/userList') },
      { path: 'add', component: _import('user/view/userAdd'), children: [
       { path: ':title', component: _import('user/view/userAdd'), props: true }
      ] },
     { path: 'edit/:id', component: _import('user/view/userEdit'), props: true }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

